<?php
define('DS', DIRECTORY_SEPARATOR);
$dirs = explode(DS, $root);
$path = '';
?>
<ul class="breadcrumb">
    <li><a href="?root=">root</a> <span class="divider">/</span></li>
    <?php foreach ($dirs as $dir): ?>
    <?php if ($dir == '') continue; ?>
    <?php $path .= $dir; ?>
    <li><a href="?root=<?php echo $path; ?>"><?php echo $dir; ?></a> <span class="divider">/</span></li>
    <?php $path .= DS; ?>
    <?php endforeach; ?>
</ul>
<table class="zebra-striped">
    <tr>
        <th>filename</th>
        <th>modified</th>
        <th style="text-align: center;">access</th>
        <th></th>
    </tr>
    <?php foreach ($infos as $info): ?>
        <tr>
            <td>
                <p>
                    <?php if (is_dir($info['file'])): ?>
                        <a href="?root=<?php echo trim($info['root'] . DS . $info['name'], DS); ?>"><?php echo $info['name']; ?></a>
                    <?php else: ?>
                        <?php echo $info['name']; ?>
                    <?php endif; ?>
                </p>
            </td>
            <td><?php echo $info['modified']; ?></td>
            <td style="text-align: center;"><?php echo $info['permission']; ?></td>
            <td class="buttons">
                <div class="buttonset">
                    <?php if (is_dir($info['file'])): ?>
                    <?php else: ?>
                        <a href="?root=<?php echo $root; ?>&view=<?php echo $info['name']; ?>" class="btn primary">view</a>
                    <?php endif; ?>
                    <a href="?root=<?php echo $root; ?>&remove=<?php echo $info['name']; ?>" class="btn error">remove</a>
                </div>
            </td>
        </tr>
    <?php endforeach; ?>
</table>
<br />
<br />
<div class="row">
    <div class="span7">
        <form action="?root=<?php echo $root; ?>" method="post" class="form-stacked">
            <input type="hidden" name="action" value="new_folder" />
            <fieldset>
                <legend>New directory</legend>
                <div class="clearfix">
                    <label>Directory name</label>
                    <div class="input">
                        <input name="name" required />
                    </div>
                </div>
                <div class="actions">
                    <button class="btn primary" type="submit">Create</button>
                </div>
            </fieldset>
        </form>
    </div>
    <div class="span7">
        <form action="?root=<?php echo $root; ?>" method="post" class="form-stacked" enctype="multipart/form-data">
            <input type="hidden" name="action" value="upload" />
            <fieldset>
                <legend>Upload file</legend>
                <div class="clearfix">
                    <label>&nbsp;</label>
                    <div class="input">
                        <input type="file" name="file" class="span5" required />
                    </div>
                </div>
                <div class="actions">
                    <button class="btn primary" type="submit">Send</button>
                </div>
            </fieldset>
        </form>
    </div>
</div>